home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / Binomial.h < prev    next >
C/C++ Source or Header  |  1989-10-19  |  2KB  |  60 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Dirk Grunwald (grunwald@cs.uiuc.edu)
  5.  
  6. This file is part of GNU CC.
  7.  
  8. GNU CC is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY.  No author or distributor
  10. accepts responsibility to anyone for the consequences of using it
  11. or for whether it serves any particular purpose or works at all,
  12. unless he says so in writing.  Refer to the GNU CC General Public
  13. License for full details.
  14.  
  15. Everyone is granted permission to copy, modify and redistribute
  16. GNU CC, but only under the conditions described in the
  17. GNU CC General Public License.   A copy of this license is
  18. supposed to have been given to you along with GNU CC so you
  19. can know your rights and responsibilities.  It should be in a
  20. file named COPYING.  Among other things, the copyright notice
  21. and this notice must be preserved on all copies.  
  22. */
  23. #ifndef _Binomial_h
  24. #define _Binomial_h 1
  25. #pragma once
  26.  
  27. #include <Random.h>
  28.  
  29. class Binomial: public Random {
  30.     int pN;
  31.     double pU;
  32. public:
  33.     Binomial(int n, double u, RNG *gen);
  34.  
  35.     int n();
  36.     int n(int xn);
  37.  
  38.     double u();
  39.     double u(int xu);
  40.  
  41.     virtual double operator()();
  42.  
  43. };
  44.  
  45. //#ifdef __OPTIMIZE__
  46.  
  47. inline Binomial::Binomial(int n, double u, RNG *gen)
  48. : (gen){
  49.   pN = n; pU = u;
  50. }
  51.  
  52. inline int Binomial::n() { return pN; }
  53. inline int Binomial::n(int xn) { int tmp = pN; pN = xn; return tmp; }
  54.  
  55. inline double Binomial::u() { return pU; }
  56. inline double Binomial::u(int xu) { double tmp = pU; pU = xu; return tmp; }
  57.  
  58. //#endif
  59. #endif
  60.